package com.itheima.web;

import com.itheima.dto.CheckGroupDto;
import com.itheima.entity.PageReq;
import com.itheima.entity.Result;
import com.itheima.service.CheckGroupService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkgroup")
public class CheckGroupController {

    @Reference
    private CheckGroupService checkGroupService;

    @PostMapping("/save")
    public Result save(@RequestBody CheckGroupDto checkGroupDto){
        return new Result(checkGroupService.saveGroup(checkGroupDto));
    }

    @GetMapping("/findAll")
    public Result findAll(){
        return new Result(checkGroupService.list());
    }

    @PostMapping("/findByPage")
    public Result findByPage(@RequestBody PageReq req) {
        return new Result(checkGroupService.findByPage(req));
    }

    @GetMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable("id") Long id){
        return new Result(checkGroupService.deleteById(id));
    }

}
